import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/assets_tool/app_colors.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/routers/jump_router.dart';
import 'package:tiktokadult/tools_base/widget/common_dialog.dart';

class SettingNoPermissionDialog extends StatelessWidget {
  final String? content;
  final String title;
  final String cancelTitle;
  final String confirmTitle;
  final bool showCancel;
  final Function()? confirmHandler;
  final bool showDividerLine;
  final String? subContent; //

  const SettingNoPermissionDialog({
    super.key,
    this.content,
    this.title = '温馨提示',
    this.cancelTitle = '稍后再说',
    this.confirmTitle = '开通会员',
    this.showCancel = true,
    this.showDividerLine = true,
    this.confirmHandler,
    this.subContent,
  });

  @override
  Widget build(BuildContext context) {
    return CommonDialog(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            title,
            style: TextStyle(color: Colors.white.withOpacity(0.9), fontSize: 20, fontWeight: FontWeight.w600),
          ),
          if (showDividerLine) ...[
            12.sizeBoxH,
            0.5.line,
          ],
          if (content?.isNotEmpty ?? false) ...[
            12.sizeBoxH,
            Text(
              content!,
              textAlign: TextAlign.center,
              style: TextStyle(color: Colors.white.withOpacity(0.5), fontSize: 16, fontWeight: FontWeight.w500),
            ),
          ],
          if (subContent?.isNotEmpty ?? false) ...[
            20.sizeBoxH,
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 16),
              child: Text(
                subContent!,
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.white.withOpacity(0.5), fontSize: 16, fontWeight: FontWeight.w400),
              ),
            ),
          ],
          31.sizeBoxH,
          Row(
            children: [
              if (showCancel) ...[
                InkWell(
                  onTap: () => Get.back(),
                  child: Container(
                    height: 44,
                    width: 112,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(color: Colors.white.withOpacity(.1), borderRadius: BorderRadius.circular(3)),
                    child: Text(
                      cancelTitle,
                      style: TextStyle(color: Color(0xff989898), fontSize: 16, fontWeight: FontWeight.w500),
                    ),
                  ),
                ),
                12.sizeBoxW,
              ],
              Expanded(
                child: InkWell(
                  onTap: () {
                    Get.back();
                    if (confirmHandler != null) {
                      confirmHandler!();
                    } else {
                      jumpToWalletPage();
                    }
                  },
                  child: Container(
                    height: 44,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(3),
                      color: AppColors.actionRed,
                    ),
                    child: Text(
                      confirmTitle,
                      style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
